import {
    ViolationDetail
} from './violation-detail.model'
const violationDetail = new ViolationDetail()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        violation: [],
        count: 0,
        active: '0',
    },

    /**
     * 生命周期函数--监听页面加载
     * @param {*} options
     */
    onLoad(options) {
        let that = this,
            param = JSON.parse(options.param)
        that._loadData(param)
    },

    /**
     * 获取所有数据
     * @param {*} param
     */
    _loadData(param) {
        let that = this
        that.getViolationData(param)
    },

    /**
     * 获取违章记录
     * @param {*} param
     */
    getViolationData(param) {
        let that = this
        violationDetail.getViolationData(param).then((res) => {
            that.setData({
                count: res.data.count,
                violation: res.data.records
            })
        })
    },

    /**
     * 切换标签
     * @param {*} options
     */
    onChangeTab(options) {
        this.setData({
            active: options.detail
        });
    }
})